using System;

namespace Charisma.Tests.Models.Fake
{
  public class FakeContext : DbContext
  {
    public IRepository NonGenericInterfaceRepository { get; set; }

    // created automatically
    public IRepository<FakeDocument> GenericInterfaceRepository { get; set; }

    // created automatically
    public Repository<FakeDocument> GenericClassRepository { get; set; }

    public InstanceRepository InstanceClassRepository { get; set; }

    // created with the help of configurator
    public IFakeRepository<FakeDocument> FakeGenericInterfaceRepository { get; set; }

    // created in dbcontext constructor
    public IFakeRepository FakeNonGenericInterfaceRepository { get; set; }

    public FakeRepository FakeClassRepository { get; set; }

    public FakeContext()
      : base("Test")
    {
      FakeNonGenericInterfaceRepository = new FakeRepository();
      FakeClassRepository = new FakeRepository();
      InstanceClassRepository = new InstanceRepository(this);
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
//        modelBuilder.Repository(context => context.GenericInterfaceRepository);
//        .HasKeyGenerator(() => new StringKeyGenerator());
//        modelBuilder.Repository(context => context.GenericClassRepository);
//        .HasKeyGenerator(() => new StringKeyGenerator());
//        modelBuilder.Repository(context => context.InstanceClassRepository);
//        .HasKeyGenerator(() => new StringKeyGenerator());
//        modelBuilder.Repository(context => context.FakeGenericInterfaceRepository);
//        .HasKeyGenerator(() => new StringKeyGenerator())
//        .HasInitializer((context) => new FakeRepository());
//        modelBuilder.Repository(context => context.FakeNonGenericInterfaceRepository);
//        .HasKeyGenerator(() => new StringKeyGenerator());
//        modelBuilder.Repository(context => context.FakeClassRepository);
//        .HasKeyGenerator(() => new StringKeyGenerator());
    }
  }
}